package com.example.administrator.android2019.ch2Activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.administrator.android2019.R;

public class RegisterActivity extends AppCompatActivity {

    private EditText editText,editText3;
    private Button btn_tj,btn_cz;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /*1、关联布局文件*/

        setContentView(R.layout.linear2);

        /*2、关联控件*/
        editText=findViewById(R.id.editText);
        editText3=findViewById(R.id.editText3);
        btn_tj=findViewById(R.id.btn_tj);
        btn_cz=findViewById(R.id.btn_cz);

        /*3、按钮的点击事件*/

        /*事件*/
        View.OnClickListener click=new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (v.getId()){
                    case R.id.btn_tj:
                        String s=editText.getText().toString()+"   "+editText3.getText().toString();
                        Toast.makeText(RegisterActivity.this,s,Toast.LENGTH_SHORT).show();
                        break;
                    case R.id.btn_cz:
                        editText3.setText(" ");
                        editText.setText(" ");
                        editText.requestFocus();
                        break;
                }


            }
        };

        /*按钮绑定上事件*/
        btn_tj.setOnClickListener(click);
       btn_cz.setOnClickListener(click);
    }
}
